import DatabaseUtils from "../utils/db-utils";
import BasicDao from "./basic-dao";

class BattleChatDao extends BasicDao {

    getColumns(): string[] {
        return ['id', 'battle_id', 'user_id', 'content', 'create_time', 'update_time'];
    }

    getTableName(): string {
        return "t_battle_chat";
    }

    /**
     * 创建聊天信息
     * @param userId
     * @param battleId
     * @param content
     * @returns {Promise<boolean>}
     */
    static createChatInfo = async (userId: string, battleId: string, content: string) => {
        const sql = `insert into t_battle_chat(user_id, battle_id, content) values(?, ?, ?)`;
        const params = [userId, battleId, content];
        await DatabaseUtils.execSql(sql, params);
        return true;
    };
}

export default BattleChatDao;